"use strict";
var _a;
var Color;
(function (Color) {
    Color[Color["Red"] = 0] = "Red";
    Color[Color["Blue"] = 1] = "Blue";
    Color[Color["Green"] = 2] = "Green";
})(Color || (Color = {}));
var PAY_STATUS;
(function (PAY_STATUS) {
    PAY_STATUS["NO_PAY"] = "\u672A\u652F\u4ED8";
    PAY_STATUS["PAY"] = "\u652F\u4ED8";
    PAY_STATUS["SUCCESS"] = "\u4EA4\u6613\u6210\u529F";
})(PAY_STATUS || (PAY_STATUS = {}));
let clothesColor = Color.Blue;
//联合类型（Union Types）
let payDesc = PAY_STATUS.PAY;
payDesc = "未支付";
payDesc = 0.1;
//类型断言
let stu_name = null;
let len = (_a = stu_name === null || stu_name === void 0 ? void 0 : stu_name.length) !== null && _a !== void 0 ? _a : 10;
//非空断言
//let str1:string|null = null;
// function foo(name:string|null)
// {
//     let strLen:number = name?.length ?? 10;
//     return strLen
// }
//类型保护 - typeof
let foo1 = function (name) {
    var _a;
    let strLen = (_a = name === null || name === void 0 ? void 0 : name.length) !== null && _a !== void 0 ? _a : 10;
    return String(strLen);
};
console.log(typeof foo1, typeof foo1("zhangsan"));
//类型保护 -  instanceof
class Animal {
}
let dog = new Animal();
dog.name = "dahuang";
console.log(dog instanceof Animal);
// 泛型函数，K 必须是 T 的键之一
function getProperty(obj, key) {
    return obj[key];
}
console.log(getProperty(dog, "name"));
//Person对象，要求遍历Person对象的所有参数的值
class Person {
    constructor() {
        this.name = '';
        this.age = 0;
        this.sex = false;
        this.className = '';
        this.teacher = '';
    }
}
let obj1 = new Person();
obj1.name = "zhangshan";
obj1.age = 18;
obj1.sex = true;
obj1.className = "22届A班";
obj1.teacher = "李老师";
//要求遍历obj1对象的所有的属性值
let entity = Object.entries(obj1);
entity.forEach(e => {
    let pname = Object.values(e)[0];
    let value = Object.values(e)[1];
    console.log(`属性名:${pname} -> ${value}`);
});
//[ 'name', 'age', 'sex', 'className', 'teacher' ]
